<template>
  <div class="modal" v-if="show">
    <div class="modal-mask" @click="handleClose"></div>
    <div class="modal-content">
      <slot />
      <!-- <img @click="handleClose" class="close" src="~@/assets/imgs/icon-close.png" alt=""> -->
    </div>
  </div>
</template>

<script>
export default {
  props: {
    value: false,
  },
  watch: {
    value: {
      handler (val) {
        this.show = val
      },
      immediate: true
    }
  },
  data () {
    return {
      show: false
    }
  },
  methods: {
    handleClose () {
      this.show = false
      this.$emit('input', false)
      this.$emit('close')
    }
  }
}
</script>

<style lang='scss' scoped>
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 99;
  &-mask {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(#000, .7);
  }
  &-content {
    position: absolute;
    top: 312px;
    left: 50%;
    transform: translateX(-50%);
    width: 654px;
    background-color: #fff;
    border-radius: 24px;
    padding: 60px 52px;
    & > .close {
      position: absolute;
      left: 50%;
      transform: translateX(-50%);
      width: 60px;
      bottom: -120px;
    }
  }
}
</style>